﻿using AiXiu.BLL;
using AiXiu.Model;
using System;
using System.Web.UI;

namespace AiXiu.WebSite
{
    /// <summary>
    /// 个人资料页
    /// </summary>
    public partial class Personal : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                //读取当前登录的用户信息
                TBUsers userInfo= IdentityManager.ReadUser();

                //显示用户信息
                //if (userInfo.Avatar == null)
                //{
                //    imgAvatar.ImageUrl = "/imgs/avatar.jpg";
                //}
                //else
                //{
                //    imgAvatar.ImageUrl = userInfo.Avatar;
                //}

                //可空类型修饰符？
                imgAvatar.ImageUrl = userInfo.Avatar ?? "/imgs/avatar.jpg";
                lblNickName.Text = userInfo.NickName ?? $"用户{userInfo.Id}";
                switch (userInfo.Sex)
                {
                    case 1:
                        lblSex.Text = "小哥哥";
                        lblSex.CssClass += " bg-color-blue";
                        break;
                    case 2:
                        lblSex.Text = "小姐姐";
                        lblSex.CssClass += " bg-color-pink";
                        break;
                    default:
                        lblSex.Visible = false;
                        break;
                }

                lblAddress.Text = userInfo.Address ?? "未知地";
                lblBirthday.Text = userInfo.Birthday.HasValue ? userInfo.Birthday.Value.ToString("M"):"未设置";
                //lblBirthday.Text = userInfo.Birthday.HasValue ?userInfo.Birthday.Value.ToString("MM-dd") : "未设置";
                lblHobby.Text = userInfo.Hobby ?? "未添加";
            }
        }
    }
}